package com.eshin.rmi;

import java.net.MalformedURLException;

import javax.annotation.Resource;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.caucho.hessian.client.HessianProxyFactory;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:spring-hession*.xml" })
public class HessionRunMain {
	@Resource(name="helloService2")
	HelloService2 helloService2;
	@Resource(name="helloService1")
	HelloService1 helloService1;
	@Test
	public void TestSpringHessionRmi() throws MalformedURLException {
		   String url = "http://localhost:8080/SpringHessionRmiServer/springHession/helloService";     
           //此处的MINA是我的项目名称       
			HessianProxyFactory factory = new HessianProxyFactory();     
			HelloService2 helloService = (HelloService2) factory.create(HelloService2.class, url);     
			
			System.out.println(helloService.doHello("yezhixin")); 
	}
	@Test
	public void TestSpringHessionRmi2() throws MalformedURLException {
		
		System.out.println(helloService2.doHello("yezhixin")); 
	}
	@Test
	public void TestSpringHessionRmi1() throws MalformedURLException {
		
		System.out.println(helloService1.doHelloById()); 
		System.out.println(helloService1.doHello("yezhixin"));
	}
}
